﻿<%@ Page Language="C#" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<%
    OleDbConnection conn = null;
    string where = Request.Params["where"];
    try {
        where = string.IsNullOrEmpty(where) ? "" : where;
        where = string.IsNullOrEmpty(where.Trim()) ? " where 建筑年平均耗电量 <>0 and 建筑年单位面积能耗 < 300" : " where 建筑年平均耗电量 <> 0  and 建筑年单位面积能耗 < 300 and " + where.Trim() + " ";
        try{
            conn = DBOp.DbConn;
            OleDbCommand comm = conn.CreateCommand();
            comm.CommandText = "select round((sum(建筑年平均耗电量))/(sum(建筑面积)), 3) as avg1, "
                                + " round(min(建筑年平均耗电量/建筑面积), 3) as min1, "
                                + " round(max(建筑年平均耗电量/建筑面积), 3) as max1, "
                                + " round(sqr(sum((((建筑年平均耗电量)/(建筑面积))-(select avg((建筑年平均耗电量)/(建筑面积)) from jz " + where + "))^2)/(select count(*) from jz " + where + ")),3) as std1"
                                + " from jz "+ where;
            DataTable dt = new DataTable();
            OleDbDataAdapter oda = new OleDbDataAdapter(comm);
            oda.Fill(dt);
            %>            
单位建筑面积年平均用电量:<%=dt.Rows[0]["avg1"] %><br />
单位建筑面积年最高用电量:<%=dt.Rows[0]["max1"] %><br />
单位建筑面积年最低用电量:<%=dt.Rows[0]["min1"] %><br />
单位建筑面积年用电量标准方差:<%=dt.Rows[0]["std1"] %><br />
            <%
        }
        catch (Exception e) { }
    }
    catch (Exception e) { }
    finally{              
        if(conn != null)
        conn.Close();
    } 
%>